 begintalkscript;

 variables;

 begintalknode 1;
	state = -1;
	nextstate = 1;
	question = "Mosadorl";
	text1 = "The vampire extends his arms at you. _Fear not, mortals. Nothing threatens you in this tower._ The voice of the vampire is dry and in a way, not impressive at all. It's like you are hearing a young man speaking.";
	text2 = "Mosadorl steps up from his chair. _Speak with me, there is much you should learn._";
	text5 = "Mosadorl sits in his chair and waits for you to act.";
	action = INTRO;

 begintalknode 2;
	state = 1;
	nextstate = -1;
	question = "I only want to drag you to the sunlight, beast! (Attack.)";
	text1 = "Mosadorl bares his fangs and stands his ground. He is nervous.";
	action = END_TALK;
	code = make_town_hostile();
 break;

 begintalknode 3;
	state = 1;
	nextstate = 2;
	question = "Who are you? Why are you here?";
	text1 = "The vampire seems to relax a bit. _I am Mosadorl, over two hundred-year-old vampire. This tower is my home, where I feed and study._";

 begintalknode 4;
	state = 2;
	nextstate = 3;
	question = "You feed? On what?";
	text1 = "_Livestock. Mostly cows. I got them when I first settled to this little valley. I haven't fed on humans for along time.";

 begintalknode 5;
	state = 3;
	nextstate = -1;
	question = "Feeding on cows works?";
	text1 = "_It doesn't have the same, flavor, as human blood. It is also weaker, but blood is blood, it doesn't matter where it's from._";

 begintalknode 6;
	state = 3;
	nextstate = 4;
	question = "Where did you originally come from?";
	text1 = "_My story is a long one. I have been a vampire for over two hundred years. Before my transformation, I was a nineteen-year-old villager, far from here. The curse of unlife has made my memory faded. There isn't much I remember about my life._";
	text2 = "_I was turned into a vampire by a power-seeking vampire. He made me a slave for him, me and others. His goal was to enslave the villages nearby and turn the people into cattle, for easy feeding. He had an army for that._";
	text3 = "_Unfortunately for him, he lived on Empire lands. The Empire sent an army to storm his castle. My former master was killed and with his death my mind was completely mine again. I managed to escape and decided to form an army of my own._";
	text4 =  "_I terrorized the peasants for some time, then the Empire sent an army to storm my castle. I managed to escape again. This time I decided to move further away and help mortals, instead of feeding on them._";
	text5 = "_After a while the villagers treated me like a friendly witch. I was content. But not a long time after that, the Empire sent an army to storm my tower. I was forced to flee again._";

 begintalknode 7;
	state = 2;
	nextstate = -1;
	question = "What do you study?";
	text1 = "_Spells, that would help me. I am sorry, but do not trust you enough to speak more of this. I must know that you possess no threat to me._";
	text2 = "_I suppose there is no harm in telling you. Vahnatai crystal magics. They could prove very useful to me and my isolation. I am not aware if you know, but during the Avernum-Empire war the Vahnatai separated large sections of Avernum._";
	text3 = "_The vahnatai created huge powerful forcefields that impenetrable by mortal wizards. I could, seal off my valley from the rest of the world. Alas the vahnatai aren't cooperative._";
	text4 = "_So I am forced to use any scraps of information I can find and, improvise._";
	action = SET_SDF 7 9 1;
	code = if (get_flag(7,3) > 0) 
			remove_string(1);
		else {
			remove_string(2);
			remove_string(3);
			remove_string(4);
}
 break;

 begintalknode 8;
	state = 4;
	nextstate = -1;
	question = "And after that you came to Faerengrove?";
	text1 = "_After that I came here. I decided that I shouldn't deal with humans at all, especially with the Empire. I sought for the most remote area I could find and end up here. Right after I arrived I created zombies to build me a tower._";
	text2 = "_Then I sought out the leader of the Empire troops and conversed with him. We reached an agreement: no troops would be sent to kill me, and I wouldn't drain a drop from his people._";
	code = inc_flag(7,10,1);
 break;

 begintalknode 9;
	state = 4;
	nextstate = -1;
	question = "Why did you help the villagers?";
	text1 = "_To ensure my survival. I had witnessed the power of the Empire twice, at that time. I figured if I posed no threat to the Empire, they would not harm me, apparently I was wrong._";
	code = inc_flag(7,10,1);
 break;

 begintalknode 10;	
	state = 1;
	nextstate = 5;
	condition = get_flag(7,3) == 0;
	question = "You can talk all you want, but I know you have attacked Grimson with your undead.";
	text1 = "The vampire shakes his head. _I haven't. Hear me out, I created the undead, but I did so only to save myself. Not long ago, I was approached by a powerful haakai. He forced me to work for him and raid the villagers._";
	text2 = "_He gave me the power to create stronger undead, but he did not trust me to command them. So you see I am not responsible for the deaths of mortals and that is why you must help me._";

 begintalknode 11;
	state = 5;
	nextstate = -1;
	question = "Who commands the undead, if not you?";
	text1 = "_The demon lord left an imp to oversee the undead._ Mosadorl smiles. _But as an imp he was easy to subdue. I encased it on a forcecage, so that the undead would just stagger around the forests aimlessly, and would not cause further harm._";
	text2 = "_If I were to kill the imp, the demon lord would notice._";

 begintalknode 12;
	state = 5;
	nextstate = -1;
	condition = get_flag(1,3) == 1;
	question = "Was the haakai by chance Kaejil Nyh'yltak?";
	text1 = "_The demon did not bother to reveal its name to me._";

 begintalknode 13;
	state = 5;
	nextstate = 6;
	question = "Help you?";
	text1 = "_Yes, to get rid of the demons. By doing this, you would also help yourselves. I only require you to destroy the undead lurking in the forests, then convince the mayor that I pose no threat._";

 begintalknode 14;
	state = 6;
	nextstate = 1;
	question = "Very well, I'll do it.";
	text1 = "Mosadorl grins. _Excellent! If you defeat enough groups of undead, the forests should be safe again. I doubt convincing the mayor is a hard task after the forests are safe._";
	text2 = "_When you've convinced the mayor, return here. I may be able to assist you further._";
	action = SET_SDF 7 3 1;
	code= toggle_quest(9,1);
 break;

 begintalknode 15;
	state = 6;
	nextstate = -1;
	condition = get_flag(7,3) < 1;
	question = "You LIE beast! Die!";
	text1 = "Mosadorl jumps back hissing and baring his fangs.";
	action = END_TALK;
	code = make_town_hostile();
 break;

 begintalknode 16;
	state = 2;
	nextstate = -1;
	question = "You feed on the innocent? Die hellspawn!";
	text1 = "Mosadorl tries to open his mouth to say something, but your attack is too ferocious.";
	action = END_TALK;
	code = make_town_hostile();
 break;

 begintalknode 17;
	state = 3;
	nextstate = -1;
	question = "Feeding on innocent livestock is just as bad as feeding on humans, unholy critter! (Attack.)";
	text1 = "The vampire seems surprised about your values.";
	action = END_TALK;
	code = make_town_hostile();
 break;

 begintalknode 18;
	state = 4;
	nextstate = -1;
	condition = get_flag(7,10) <= 2;
	question = "Enough of this! The blood of those people must me avenged!";
	text1 = "Mosadorl reluctantly bares his fangs.";
	action = END_TALK;
	code = make_town_hostile();
 break;

 begintalknode 19;
	state = 1;
	nextstate = 7;
	condition = get_flag(7,3) == 2;
	question = "I talked with the mayor, you are safe again.";
	text1 = "Mosadorl grins jubilantly. _This is fantastic news! Thank you mortals. You have ensured my survival for at least a few months._";

 begintalknode 20;
	state = 7;
	nextstate = -1;
	question = "You said you could help us?";
	text1 = "_Ah yes! No doubt you are seeking a way to banish the demon lord responsible for the suffering of the mortals in this valley. I managed to scry his location without him finding out._";
	text2 = "_He is residing in an old fort in the most northern part of this valley. I have also found out that he has the small passage to his stronghold heavily guarded. Fortunately there is another way._";
	text3 = "_You must travel to a small hut in the north-western valley. There you should be able to find an underground passage to the haakai's lands. Also if you have an item belonging to the haakai, you should bring it to me._";
	action = SET_SDF 10 0 1;

 begintalknode 21;
	state = 7;
	nextstate = 8;
	condition = get_flag(10,0) == 1 && has_special_item(2) == 1;
	question = "I found this amulet, is it suitable?";
	text1 = "Mosadorl takes the goblin amulet and inspects it. _Yes, I sense the essence of the haakai within this amulet. Wait here! I will return shortly._ Mosadorl paces out of his throne room to the door north of him.";
	text2 = "It takes quite a while before he returns. Mosadorl holds the amulet carefully in front of you with tongs. _Here take it back! Do not be frightened. The amulet would only burn me, for I invoked a powerful holy ritual on it._";
	text3 = "You take the amulet, it seems to be safe.";
	code = change_spec_item(2,-1);
		change_spec_item(0,1);
		toggle_quest(9,0);
		award_party_xp(50,30);
		set_flag(7,3,3);
 break;

 begintalknode 22;
	state = 1;
	nextstate = -1;
	condition = get_flag(7,9) == 1 && get_flag(7,3) > 0;
	question = "Could you tell me what you study?";
	text1 = "_I suppose there is no harm in telling you. Vahnatai crystal magics. They could prove very useful to me and my isolation. I am not aware if you know, but during the Avernum-Empire war the Vahnatai separated large sections of Avernum._";
	text2 = "_The vahnatai created huge powerful forcefields that impenetrable by mortal wizards. I could, seal off my valley from the rest of the world. Alas the vahnatai aren't cooperative._";
	text3 = "_So I am forced to use any scraps of information I can find and, improvise._";

 begintalknode 23;
	state = 8;
	nextstate = -1;
	question = "You know holy rituals?";
	text1 = "Mosadorl grins. _Surprised? That is an ancient ritual known by the, priests of my, tribe. It was taught to me when I was, alive. I must have been an acolyte._";

 begintalknode 24;
	state = 8;
	nextstate = -1;
	question = "Exactly what does the ritual do?";
	text1 = "_When brought close to the demon lord, the amulet will charge up a holy bolt, which it will blast at the demon lord. The bolt will not exactly harm the demon, but it will make it vulnerable to conventional weapons._";
	text2 = "_You may have heard, some powerful demons are practically immune to ordinary weaponry. This will also help you further, for I have placed other rituals in it. It will work best against the demon lord's own magic._";

 begintalknode 25;
	state = -1;
	nextstate = 26;
	question = "Caught ya!";
	text1 = "Mosadorl appears in front of you. He stares at you angrily, with his hand extended towards you. _Give me the tome._ He produces blankly.";

 begintalknode 26;
	state = 26;
	nextstate = -1;
	question = "Alright here! How did you know?";
	text1 = "Mosadorl snatches the book from your hands. _You opened my sarcophagus, killed my guardians and STOLE my book! How could I not have sensed it._ Mosadorl sighs. _Trust me mortals. I am not your enemy, but I do not like thieves!_";
	text2 = "The vampire turns away from you.";
	action = END_TALK;
	code = change_spec_item(9,-1);
		set_flag(7,11,1);
 break;

 begintalknode 27;
	state = 26;
	nextstate = 27;
	question = "What tome?";
	text1 = "_The tome you stole from my sarcophagus! The tome which in order to get, you killed my guardians! Hand it over!_ Mosadorl looks like he is prepared for a fight. You ought to do what he says.";

 begintalknode 28;
	state = 27;
	nextstate = -1;
	question = "Alright! Here, take it.";
	text1 = "Mosadorl snatches the book from your hands and sighs. _Trust me mortals. I am not your enemy, but I do not like thieves!_ The vampire turns away from you.";
	action = END_TALK;
	code = change_spec_item(9,-1);
		set_flag(7,11,1);
 break;

 begintalknode 29;
	state = 27;
	nextstate = -1;
	question = "You'll have to pry it from my dead fingers vampire!";
	text1 = "Mosadorl jumps back baring his fangs.";
	action = END_TALK;
	code = make_town_hostile();
		set_flag(7,11,1);
 break;

 begintalknode 30;
	state = 26;
	nextstate = -1;
	question = "You will never get this tome back vampire! (Attack.)";
	action = END_TALK;
	code = make_town_hostile();
		set_flag(7,11,1);
 break;

 begintalknode 31;
	state = 1;
	nextstate = -1;
	condition = get_flag(17,17) >= 2 && get_flag(17,9) == 1;
	question = "The demon lord has been banished!";
	text1 = "Mosadorl bursts into almost insane laughter. _Then I am safe from him! Wonderful!_ Then his face turns serious. _But the Empire will hear of me when they come here to investigate. I must make haste and be prepared._";
	text2 = "_On my behalf mortals, thank you._";